package com.buric.api.factory.admin;

import com.buric.api.dto.admin.LoginAdmin;
import com.buric.api.service.admin.AdminApiService;
import com.buric.common.data.R;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author: zhou.wei
 * @description
 * @date: 2024/5/10 16:27
 */

@Component
public class AdminApiFallBackFactory implements FallbackFactory<AdminApiService> {

    private static final Logger log = LoggerFactory.getLogger(AdminApiFallBackFactory.class);

    @Override
    public AdminApiService create(Throwable cause) {
        log.error("用户服务调用失败:",cause);

        return new AdminApiService(){
            @Override
            public R<LoginAdmin> getUserByUsername(String username) {
                return R.fail("获取管理员信息失败");
            }
        };
    }
}
